package com.longchat.controller.admin.award;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.longchat.domain.award.Activity;
import com.longchat.domain.award.Award;
import com.longchat.domain.award.AwardLog;
import com.longchat.dto.comm.ResultInfo;
import com.longchat.service.inter.award.IAwardService;
import com.longchat.utils.vo.ResultWrapper;

@Controller("lottoryManage")
@RequestMapping("/admin/activity")
public class LotteryController {
	
	@Autowired
	private IAwardService awardService;
	@RequestMapping("/lottery")
	public ModelAndView list(Integer id){
		ModelAndView model = new ModelAndView("/admin/award/lottery_list");
		model.addObject("result", awardService.findAllAward(id));
		return model;
	}
	@RequestMapping("")
	public ModelAndView activityList(){
		ModelAndView model = new ModelAndView("/admin/award/activity_list");
		model.addObject("result",awardService.findAllActivity());
		return model;
	}
	@ResponseBody
	@RequestMapping("/update")
	public ResultInfo updateActivity(Activity activity){
		return awardService.updateActivity(activity);
	}
	
	@RequestMapping("/updateDialog")
	public ModelAndView activityUpdateDialog(int id){
		ModelAndView modelAndView = new ModelAndView("/admin/award/activity_modify");
		modelAndView.addObject("activity", awardService.findActivity(id));
		return modelAndView;
	}
	@ResponseBody
	@RequestMapping("/lottery/update")
	public ResultWrapper<String> update(Award award){
		return awardService.updateAward(award);
	}
	@RequestMapping("/lottery/updateDialog")
	public ModelAndView updateDialog(int id){
		ModelAndView modelAndView = new ModelAndView("/admin/award/lottery_modify");
		modelAndView.addObject("award", awardService.findAwardById(id));
		return modelAndView;
	}
	@RequestMapping("/lottery/awardLogs")
	public ModelAndView awardLogList(){
		ModelAndView model = new ModelAndView("/admin/award/awardLog_list");
		model.addObject("logs", awardService.findAllAwardLogs());
		return model;
	}
	@ResponseBody
	@RequestMapping("/lottery/awardLogs/list")
	public List<AwardLog> findAwardLogs(){
		return awardService.findAllAwardLogs();
	}
	
}
